/*
 * Copyright 2006-2008 Michele Mostarda ( michele.mostarda@gmail.com ).
 * All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.graphnav.swing.event;

import org.graphnav.swing.GraphPanel;
import org.graphnav.swing.Node;

import java.awt.Dimension;
import java.util.EventObject;

/**
 * Any event generated by a a {@link org.graphnav.swing.GraphPanel}.
 */
public class GraphPanelEvent extends EventObject {

    private Node[] selectedNodes;

    private Node[] overlappedNodes;

    private Dimension bounds;

    /**
     * Constructs a prototype Event.
     *
     * @param source The panel on which the Event initially occurred.
     * @throws IllegalArgumentException if source is null.
     */
    public GraphPanelEvent(GraphPanel source, Node[] selectedNodes) {
        super(source);
        this.selectedNodes = selectedNodes;
    }

    /**
     * Constructor.
     *
     * @param source
     * @param selectedNodes
     * @param overlappedNodes
     */
    public GraphPanelEvent(GraphPanel source, Node[] selectedNodes, Node[] overlappedNodes) {
        super(source);
        this.selectedNodes = selectedNodes;
        this.overlappedNodes = overlappedNodes;
    }

    /**
     * Constructor.
     * 
     * @param source
     * @param b
     */
    public GraphPanelEvent(GraphPanel source, Dimension b) {
        super(source);
        this.bounds = b;
    }

    public Node[] getSelectedNodes() {
        return selectedNodes;
    }

    public Node getAffectedNode() {
        return selectedNodes.length > 0 ? selectedNodes[0] : null;
    }


    public Node[] getOverlappedNodes() {
        return overlappedNodes;
    }

    public Dimension getBounds() {
        return bounds;
    }

}
